<template>
  <div class="box">
    <h2>子组件 add</h2>
    从父组件中获取的值:<label for="">{{num}}</label>
    <br>
    <button @click="Add">值+1</button>
  </div>
</template>
<style lang="css">
  .box{
    border:1px solid #ccc;
    width:200px;
    padding:5px;
    margin: 20px;
  }
</style>
<script>
import { mapState } from "vuex";
export default {
  name: 'AddItem',
  computed:{
      ...mapState(["num"])
  },
  methods:{
      Add(){
          this.$store.commit('addNum')
      }
  }
  
}
</script>